#include <iostream>
#include <vector>
#include <queue>
#include <tuple>
using namespace std;

int main()
{
        int n, m, k, s, t;
        cin >> n >> m >> k;
        cin >> s >> t;

        vector<vector<vector<int>>> gh(n);
        vector<vector<int>> dis(n, vector<int>(k + 1, INT32_MAX));
        vector<vector<int>> vis(n, vector<int>(k + 1, 0));

        for(int i = 0; i < m; i++){
                int u, v , w;
                cin >> u >> v >> w;
                gh[u].push_back({v, w});
                gh[v].push_back({u, w});
        }

        int ans = 0;
        priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<>> pq;
        dis[s][k] = 0;
        pq.emplace(0, s, k);
        while(!pq.empty()){
                auto [w, u, k] = pq.top();
                pq.pop();
                if(vis[u][k]){
                        continue;
                }
                vis[u][k] = 1;

                if(u == t){
                        ans = w;
                        break;
                }

                for(auto e : gh[u]){
                        int v = e[0], cost = e[1];
                        if(cost + w < dis[v][k] && !vis[v][k]){
                                dis[v][k] = cost + w;
                                pq.emplace(cost + w, v, k);
                        }

                        if(k > 0){
                                cost = w;
                                if(cost < dis[v][k - 1] && !vis[v][k - 1]){
                                        dis[v][k - 1] = cost;
                                        pq.emplace(cost, v, k - 1);
                                }
                        }
                }
        }
        cout << ans <<endl;
        return 0;
}